The IP forwarding algorithm is related to the topic of routing and gives a more directed approach in forwarding datagrams over a network. In order to achieve a successful transfer of data the algorithm uses a routing table to select a next-hop router as the next destination for a datagram. The IP address that is selected is known as the next-hop address.[1]
The IP Forwarding Algorithm states:
Given a destination IP address, D, and network prefix, N:
if (N matches a directly connected network address) Deliver datagram to D over that network; else if (N does not match a network address and routing table contains route for N) Send datagram to next-hop address listed in the routing table; else if (N does not match a network and routing table does not contain route for N and there exists a default route) Send datagram to default route; else Send forwarding error message;